package com.hr.common.retrun;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class R<T> {
    private Integer code;
    private String msg;
    private T data;

    public static <T> R<T> ok(String message, T data) {
        return new R(200, message, data);
    }

    public static R ok(String message) {
        return new R(200, message, null);
    }

    public static <T> R<T> ok(T data) {
        return new R(200, "ok", data);
    }

    public static R error(String message) {
        return new R(500, message, null);
    }

    public static R error(Object data) {
        return new R(500, "error", data);
    }
}
